package com.jule.teenpatti.game.network;

import com.jule.teenpatti.game.network.protocol.ClientAck;
import com.jule.teenpatti.game.network.protocol.acks.*;
import com.jule.teenpatti.game.service.holder.FunctionIdHolder;

import java.util.HashMap;
import java.util.Map;

public class ServerOps {
    private static Map<Class<? extends ClientAck>, Integer> opcodes = new HashMap<>();

    static {

        opcodes.put(GatePongAck_01.class, 0x08000000 | 1);
        opcodes.put(JoloGame_ApplyJoinTableAck_50000.class, FunctionIdHolder.Game_ACK_ApplyJoinTable);
        opcodes.put(JoloGame_ApplySitDownAck_50001.class, FunctionIdHolder.Game_ACK_ApplySiteDown);
        opcodes.put(JoloGame_ApplyStandUpAck_50002.class, FunctionIdHolder.Game_ACK_ApplyStandUp);
        opcodes.put(JoloGame_ApplyLeaveAck_50003.class, FunctionIdHolder.Game_ACK_ApplyLeave);
        opcodes.put(JoloGame_ApplyBuyInAck_50004.class, FunctionIdHolder.Game_ACK_ApplyBuyIn);
        opcodes.put(JoloGame_ApplyBetAck_50005.class, FunctionIdHolder.Game_ACK_ApplyBet);
        opcodes.put(JoloGame_ApplySeeCardAck_50006.class, FunctionIdHolder.Game_ACK_ApplySeeCard);
        opcodes.put(JoloGame_ApplySideShowAck_50007.class, FunctionIdHolder.Game_ACK_ApplySideShow);
        opcodes.put(JoloGame_ApplyShowAck_50008.class, FunctionIdHolder.Game_ACK_ApplyShow);
        opcodes.put(JoloGame_GetSideShowStateAck_50009.class, FunctionIdHolder.Game_ACK_GetSideShowState);
        opcodes.put(JoloGame_IsAllowSideShowAck_50010.class, FunctionIdHolder.Game_ACK_IsAllowSideShow);
        opcodes.put(JoloGame_ApplyChooseUserAck_50011.class, FunctionIdHolder.Game_ACK_ApplyChooseUser);
        opcodes.put(JoloGame_ApplyFoldAck_50012.class, FunctionIdHolder.Game_ACK_ApplyFold);
        opcodes.put(JoloGame_ChangeCardAck_50013.class, FunctionIdHolder.Game_ACK_ChangeCard);
        opcodes.put(JoloGame_RewardCroupierAck_50050.class, FunctionIdHolder.Game_ACK_RewardCroupier);
        opcodes.put(JoloGame_GiftsListAck_50051.class, FunctionIdHolder.Game_ACK_GiftsList);
        opcodes.put(JoloGame_GiveGiftsAck_50052.class, FunctionIdHolder.Game_ACK_GiveGifts);
        opcodes.put(JoloGame_ChangeCroupierAck_50053.class, FunctionIdHolder.Game_ACK_ChangeCroupier);
        opcodes.put(JoloGame_ItemStatusAck_50054.class, FunctionIdHolder.Game_ACK_ItemStatus);
        opcodes.put(JoloGame_TestUnlockAck_50055.class,FunctionIdHolder.Game_ACK_TestUnlock);
        opcodes.put(JoloGame_OtherPlayerInfoAck_50014.class, FunctionIdHolder.Game_ACK_OtherUserInfo);
        opcodes.put(JoloGame_TablePlay_CurrActionPlayerInfoAck_50015.class, FunctionIdHolder.Game_ACK_CurrActionPlayerInfo);
        opcodes.put(JoloGame_ReconnectAck_50016.class, FunctionIdHolder.Game_ACK_Reconnect);
        opcodes.put(JoloGame_Choose_PlayTypeAck_50017.class, FunctionIdHolder.Game_ACK_ChoosePlayType);

        opcodes.put(JoloGame_TaskListAck_50060.class,FunctionIdHolder.Game_ACK_TaskList);
        opcodes.put(JoloGame_TaskAwardAck_50062.class,FunctionIdHolder.Game_ACK_TaskAward);
        opcodes.put(JoloGame_PlayRecordsAck_50063.class,FunctionIdHolder.Game_ACK_GameRecords);
        opcodes.put(JoloGame_GamePrepareAck_50064.class,FunctionIdHolder.Game_ACK_GamePrepare);
        opcodes.put(JoloGame_FullPressureShowAck_50065.class,FunctionIdHolder.Game_ACK_FullPressureShow);
        opcodes.put(JoloGame_ChatAck_80001.class, 0x08000000 | 80001);

    }

    /**
     * @param clazz
     * @return
     */
    public static int getOpCode(Class<? extends ClientAck> clazz) {
        if (!opcodes.containsKey(clazz)) {
            throw new IllegalArgumentException("opCode not find");
        }
        return opcodes.get(clazz);
    }
}
